#include"SerCliMode.hpp"
#include<iostream>
#include<ctime>
using std::cout;
using std::endl;
void* productor(void* argc){
    blockQueue<int>* pBq=static_cast<blockQueue<int>*>(argc);
    while(true)
    {
        int data=rand()%10;
        pBq->push(data);

        cout<<"productor has push data ::"<<data<<endl;
        sleep(1);
    }
    return nullptr;
}

void* Server(void* argc)
{
    blockQueue<int>*pBq=static_cast<blockQueue<int>*>(argc);
    while(true)
    {
        int data=pBq->pop();
        cout<<"server has pop data:"<<data<<endl;
        sleep(2);
    }
    return nullptr;
}

int main()
{
    srand((unsigned long)time(nullptr)^getpid());
    blockQueue<int> bq;
    pthread_t cre,ser;
    pthread_create(&cre,nullptr,productor,&bq);
    pthread_create(&ser,nullptr,Server,&bq);
    pthread_join(cre,nullptr);
    pthread_join(ser,nullptr);
    return 0;

}
